//引入  创建子 切换
import {createSlice} from '@reduxjs/toolkit'
const  cartSlice=createSlice({
        name:"cart",//切片名字
      initialState:{   //初始值  仓库李的值
         user:"赵恩毅",
         age:20
      },
      //修改仓库的值
      reducers:{
            addAge(state,{payload,type}){
                    state.age=state.age+payload;
            },

            subAge(state,{payload,type}){
                console.log('年龄的减少')
                state.age=state.age-payload;
            }
      }
})






//导出方法
export const {addAge,subAge} =cartSlice.actions;
//导出切片
export default cartSlice.reducer



